package cn.nbt.busManage.model.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.time.LocalDateTime;
import java.util.List;

@Entity
@Data
@EqualsAndHashCode(callSuper = true)
@Table(name = "bus")
public class Bus extends BaseEntity   {
    @ManyToOne(cascade = CascadeType.PERSIST)
    @JoinColumn(name = "route_id", referencedColumnName = "id")
    private Route route;
    @ManyToMany(cascade = CascadeType.PERSIST)
    @JoinTable(name = "bus_driver",
            joinColumns = @JoinColumn(name = "bus_id"),
            inverseJoinColumns = @JoinColumn(name = "driver_id"))
    private List<Driver> drivers;
    @Column(name = "license_plate")
    private String licensePlate;
    @Column(name = "model")
    private String model;
    @Column(name = "capacity")
    private Integer capacity;
    @Column(name = "status")
    private Integer status;
    @Column(name = "last_maintenance_date")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime lastMaintenanceDate;
    @Column(name = "next_inspection_date")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime nextInspectionDate;
}
